<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>添加法条</title>
<link rel="stylesheet" type="text/css" href="css/css.css" />
<script type="text/javascript" src="js/jquery.min.js"></script>
</head>
<body>
	<div id="pageAll">
		<div class="pageTop">
			<div class="page" >
				<span><a href="law.html">返回</a></span>&nbsp;-&nbsp;新增法条
			</div>
		</div>
		<div class="page" id="app">
			<!-- 会员注册页面样式 -->
			<div class="banneradd bor">
				<div class="baTopNo">
					<span>新增法条</span>
				</div>
				<div class="baBody">
					<div class="bbD">
						法条标题:<input type="text" class="input3" v-model="law.lawtit" />
					</div>
					<div class="bbD">
						链接地址:<input type="text"class="input3" v-model="law.lawlink" />
					</div>
					<div class="bbD">
						日期:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text"class="input3" v-model="law.lawdate"/>
					</div>
					<div class="bbD">
						<p class="bbDP">
							<button @click="add" class="btn_ok btn_yes" href="#">发布</button>
						</p>
					</div>
				</div>
			</div>

			<!-- 添加管理员页面样式end -->
		</div>
	</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/vue"></script>
<script src="https://cdn.jsdelivr.net/npm/vue-resource@1.5.0"></script>
<script>
	new Vue({
		el: '#app',
		data() {
			return {
				law: {
					lawtit: '',
					lawlink: '',
					lawdate: ''
				}
			}
		},
		methods: {
			add: function() {
				if(!this.law.lawtit) {
					alert('标题不能为空');
					return;
				}
				if(!this.law.lawlink) {
					alert('链接不能为空');
					return;
				}
				if(!this.law.lawdate) {
					alert('时间不能为空');
					return;
				}
				this.$http.post(`http://localhost:8080/law/add`,this.law)
				.then(
				res =>{
					let data = res.body;
					if(data.code === '200') {
						alert('添加成功');
					}else {
						alert(data.desc);
					}
				},
				res =>{
					alert(`时间格式错误`);
				}
			);
			}
		}
	});
</script>
</html>